/*
 * GalaxyView.cpp
 *
 *  Created on: 2011-5-5
 *      Author: Administrator
 */

#include "GalaxyView.h"
#include <FMedia.h>

using namespace Osp::App;
using namespace Osp::Graphics;
using namespace Osp::Media;
using namespace Osp::Ui;
using namespace Osp::Ui::Controls;

namespace Galaxy {
GalaxyView::GalaxyView():__pThread(NULL) {
}

GalaxyView::~GalaxyView() {
}

bool GalaxyView::Initialize() {
	Form::Construct(Osp::Ui::Controls::FORM_STYLE_NORMAL);


	return true;
}

result GalaxyView::OnInitializing(void) {
	result r = E_SUCCESS;

	AddTouchEventListener(*this);
    Touch touch;
    r = touch.SetMultipointEnabled(*this, true);
    if(IsFailed(r)){
    	AppLog("Multi touch %ls", GetErrorMessage(r));
    }

	__pThread = new GalaxyThread(this);

	return r;
}

result GalaxyView::OnTerminating(void) {
	result r = E_SUCCESS;

	return r;
}

result GalaxyView::OnDraw(){
	result r = E_SUCCESS;

	AppLog("GalaxyView::OnDraw()---Begin");

	Canvas* pCanvas = GetCanvasN();
	//__pThread->DoDraw(pCanvas);

	delete pCanvas;
	pCanvas = NULL;
	AppLog("GalaxyView::OnDraw()---End");
	return r;
}

void GalaxyView::OnActionPerformed(const Osp::Ui::Control& source, int actionId) {
	switch (actionId) {
	default:
		break;
	}
}

GalaxyThread* GalaxyView::GetThread(){
	return __pThread;
}

void GalaxyView::OnTouchPressed(const Control& source,
	const Osp::Graphics::Point& currentPosition, const Osp::Ui::TouchEventInfo & touchInfo){
	AppLog("GalaxyView::OnTouchPressed---Begin");
	//__pThread->OnTouchPressed(source,currentPosition,touchInfo);
}

void GalaxyView::OnTouchLongPressed(const Osp::Ui::Control& source,
	const Osp::Graphics::Point& currentPosition, const Osp::Ui::TouchEventInfo& touchInfo){
	AppLog("GalaxyView::OnTouchLongPressed---Begin");
	//__pThread->OnTouchLongPressed(source,currentPosition,touchInfo);
}

void GalaxyView::OnTouchReleased(const Osp::Ui::Control& source,
	const Osp::Graphics::Point& currentPosition, const Osp::Ui::TouchEventInfo& touchInfo){
	AppLog("GalaxyView::OnTouchMoved---Begin");
	//__pThread->OnTouchReleased(source,currentPosition,touchInfo);
}

void GalaxyView::OnTouchMoved(const Osp::Ui::Control& source,
	const Osp::Graphics::Point& currentPosition, const Osp::Ui::TouchEventInfo& touchInfo){
	AppLog("GalaxyView::OnTouchMoved---Begin");
	__pThread->OnTouchMoved(source,currentPosition,touchInfo);
}

void GalaxyView::OnTouchDoublePressed(const Osp::Ui::Control& source,
	const Osp::Graphics::Point& currentPosition, const Osp::Ui::TouchEventInfo& touchInfo){
	AppLog("GalaxyView::OnTouchDoublePressed---Begin");
	//__pThread->OnTouchDoublePressed(source,currentPosition,touchInfo);
}

void GalaxyView::OnTouchFocusIn(const Osp::Ui::Control& source,
	const Osp::Graphics::Point& currentPosition, const Osp::Ui::TouchEventInfo& touchInfo){
	AppLog("GalaxyView::OnTouchFocusIn---Begin");
	//__pThread->OnTouchFocusIn(source,currentPosition,touchInfo);
}

void GalaxyView::OnTouchFocusOut(const Osp::Ui::Control& source,
	const Osp::Graphics::Point& currentPosition, const Osp::Ui::TouchEventInfo& touchInfo){
	AppLog("GalaxyView::OnTouchFocusOut---Begin");
	//__pThread->OnTouchFocusOut(source,currentPosition,touchInfo);
}
}

